import { Layout } from "antd";
import React from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import HeaderBar from "../components/layout/HeaderBar";
import SiderBar from "../components/layout/SiderBar";
import NotFound from "./../pages/404";
import Home from "./../pages/home/Home";
import ManagerList from "./../pages/system/manager";
import RoleList from "./../pages/system/role";
import SetUp from "./../pages/system/setup";
import UserList from "./../pages/user/List";
class Index extends React.Component {
  render() {
    const loggedIn = window.localStorage.getItem("loggedIn");
    const mainPage = (
      <Layout>
        <SiderBar></SiderBar>
        <Layout>
          <HeaderBar key={this.props.history}></HeaderBar>
          <div>
            <Switch>
              <Route exact path="/" component={Home} />
              <Route path="/user/list" component={UserList}></Route>
              <Route path="/system/manager" component={ManagerList}></Route>
              <Route path="/system/role" component={RoleList}></Route>
              <Route path="/system/setup" component={SetUp}></Route>

              <Route component={NotFound} />
            </Switch>
          </div>
        </Layout>
      </Layout>
    );
    return loggedIn ? mainPage : <Redirect to="/login" />;
  }
}

export default Index;
